{extend name="public/common"} {block name="body"}
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-admin-role-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">会员等级：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<dl class="permission-list">
					<dt>
						<label>
							<input type="checkbox" value="" name="user-Character-0" id="user-Character-1">
							全部等级</label>
					</dt>
					<dd>
						<dl class="cl permission-list2">
							<dd>
							{volist name="level" id="lv"}
								<label style="margin-right:15px;">
									<input class="lv_id" type="checkbox" value="{$lv.id}" name="lv_id[]" {if condition="in_array($lv.id,$level_pay)"}checked{/if}>
									{$lv.class_name}</label>
							{/volist}
							</dd>
						</dl>
					</dd>
				</dl>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
			</div>
		</div>
	</form>
</article>

  {/block}
  {block name="js"}
<script type="text/javascript" src="__SYSMET__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript">
    $(function() {

    	$("#form-admin-role-add").submit(function(){
    		var lv_id = $('input[class=lv_id]:checked').length;
    		if(lv_id == 0){
    			layer.msg('请选择等级', {icon: 5});
    			return false;
    		}
    		$.post(
    			"{:url('paysetting/Jurisdiction')}?id={:input('get.id')}",
    			$(this).serialize(),
    			function(d){
    				if(d.code == 1){
    					layer.open({
    						  content: d.msg,
    						  icon: 6,
    						  yes: function(index, layero){
    						    parent.location.reload()
    						  }
    						});  
    				}else{
    					layer.msg(d.msg, {icon: 5});
    					return false;
    				}
    				
    			},'json'
    		)
    		return false;
    	});
        $('.skin-minimal input').iCheck({
          checkboxClass : 'icheckbox-blue',
          radioClass : 'iradio-blue',
          increaseArea : '20%'
        });
        $("#tab-system").Huitab({
          index : 0
        });
        $(".permission-list dt input:checkbox").click(function(){
    		$(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
    	});
    	$(".permission-list2 dd input:checkbox").click(function(){
    		var l =$(this).parent().parent().find("input:checked").length;
    		var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
    		if($(this).prop("checked")){
    			$(this).closest("dl").find("dt input:checkbox").prop("checked",true);
    			$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
    		}
    		else{
    			if(l==0){
    				$(this).closest("dl").find("dt input:checkbox").prop("checked",false);
    			}
    			if(l2==0){
    				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
    			}
    		}
    	});
    	

      });
    
    </script>
  {/block}